using System;
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;

using Weazel.Math;

public class Register_euclid_m : IRegister
{
    
    internal Integer Value;
    
    internal String EntityName;
    
    /// The cycle for which the value field was last evaluated (debug purpose)
    internal Int32 Cycle;
    
    // Used to evaluate expression: m >= n
    internal Integer Value_binaryexpression66;
    
    // Used to evaluate expression: m - n
    internal Integer Value_binaryexpression69;
    
    // Used to evaluate expression: m >= n ? m - n : m
    internal Integer Value_ternaryexpression71;
    
    // The constant value 1
    // The constant value 1
    internal Integer Constant_1;
    
    // Used to evaluate expression: m >> 1
    // Used to evaluate expression: m >> 1
    internal Integer Value_binaryexpression42;
    
    /// Caches the previous register value.
    internal Integer StoredValue;
    
    public virtual void Evaluate()
    {
      switch(Simulator.controller_euclid_ctl.CurrentControlStep)
      {
      case 0:
        Debug.Assert((Simulator.outPort_test_euclid_m.Cycle == Simulator.CurrentCycle));
        this.Value.ValueCopy(Simulator.outPort_test_euclid_m.Value);
        break;
      case 2:
        if ((Simulator.register_euclid_m.StoredValue >= Simulator.register_euclid_n.StoredValue))
        {
            this.Value_binaryexpression66 = Integer.One;
        }
        else
        {
            this.Value_binaryexpression66 = Integer.Zero;
        }
        Integer.Subtract(ref this.Value_binaryexpression69, Simulator.register_euclid_m.StoredValue, Simulator.register_euclid_n.StoredValue);
        if ((Integer.Zero != this.Value_binaryexpression66))
        {
            this.Value_ternaryexpression71.ValueCopy(this.Value_binaryexpression69);
        }
        else
        {
            this.Value_ternaryexpression71.ValueCopy(Simulator.register_euclid_m.StoredValue);
        }
        this.Value.ValueCopy(this.Value_ternaryexpression71);
        break;
      case 4:
        Integer.ShiftRight(ref this.Value_binaryexpression42, Simulator.register_euclid_m.StoredValue, this.Constant_1.ToInt());
        this.Value.ValueCopy(this.Value_binaryexpression42);
        break;
      case 5:
        Integer.ShiftRight(ref this.Value_binaryexpression42, Simulator.register_euclid_m.StoredValue, this.Constant_1.ToInt());
        this.Value.ValueCopy(this.Value_binaryexpression42);
        break;
      case 6:
        Debug.Assert((Simulator.outPort_test_euclid_m.Cycle == Simulator.CurrentCycle));
        this.Value.ValueCopy(Simulator.outPort_test_euclid_m.Value);
        break;
      }
    }
    
    public virtual void Initialize()
    {
        this.Value = new Integer(16, false);
        this.Value_binaryexpression66 = new Integer(1, false);
        this.Value_binaryexpression69 = new Integer(16, false);
        this.Value_ternaryexpression71 = new Integer(16, false);
        this.Constant_1 = new Integer(2, "1", false);
        this.Value_binaryexpression42 = new Integer(16, false);
        this.StoredValue = new Integer(16, false);
    }
    
    public virtual void Tick()
    {
        this.StoredValue.ValueCopy(this.Value);
    }
}

public class Register_euclid_n : IRegister
{
    
    internal Integer Value;
    
    internal String EntityName;
    
    /// The cycle for which the value field was last evaluated (debug purpose)
    internal Int32 Cycle;
    
    // Used to evaluate expression: n > m
    internal Integer Value_binaryexpression76;
    
    // Used to evaluate expression: n - m
    internal Integer Value_binaryexpression79;
    
    // Used to evaluate expression: n > m ? n - m : n
    internal Integer Value_ternaryexpression81;
    
    // The constant value 1
    // The constant value 1
    internal Integer Constant_1;
    
    // Used to evaluate expression: n >> 1
    // Used to evaluate expression: n >> 1
    internal Integer Value_binaryexpression54;
    
    /// Caches the previous register value.
    internal Integer StoredValue;
    
    public virtual void Evaluate()
    {
      switch(Simulator.controller_euclid_ctl.CurrentControlStep)
      {
      case 0:
        Debug.Assert((Simulator.outPort_test_euclid_n.Cycle == Simulator.CurrentCycle));
        this.Value.ValueCopy(Simulator.outPort_test_euclid_n.Value);
        break;
      case 2:
        if ((Simulator.register_euclid_n.StoredValue > Simulator.register_euclid_m.StoredValue))
        {
            this.Value_binaryexpression76 = Integer.One;
        }
        else
        {
            this.Value_binaryexpression76 = Integer.Zero;
        }
        Integer.Subtract(ref this.Value_binaryexpression79, Simulator.register_euclid_n.StoredValue, Simulator.register_euclid_m.StoredValue);
        if ((Integer.Zero != this.Value_binaryexpression76))
        {
            this.Value_ternaryexpression81.ValueCopy(this.Value_binaryexpression79);
        }
        else
        {
            this.Value_ternaryexpression81.ValueCopy(Simulator.register_euclid_n.StoredValue);
        }
        this.Value.ValueCopy(this.Value_ternaryexpression81);
        break;
      case 3:
        Integer.ShiftRight(ref this.Value_binaryexpression54, Simulator.register_euclid_n.StoredValue, this.Constant_1.ToInt());
        this.Value.ValueCopy(this.Value_binaryexpression54);
        break;
      case 5:
        Integer.ShiftRight(ref this.Value_binaryexpression54, Simulator.register_euclid_n.StoredValue, this.Constant_1.ToInt());
        this.Value.ValueCopy(this.Value_binaryexpression54);
        break;
      case 6:
        Debug.Assert((Simulator.outPort_test_euclid_n.Cycle == Simulator.CurrentCycle));
        this.Value.ValueCopy(Simulator.outPort_test_euclid_n.Value);
        break;
      }
    }
    
    public virtual void Initialize()
    {
        this.Value = new Integer(16, false);
        this.Value_binaryexpression76 = new Integer(1, false);
        this.Value_binaryexpression79 = new Integer(16, false);
        this.Value_ternaryexpression81 = new Integer(16, false);
        this.Constant_1 = new Integer(2, "1", false);
        this.Value_binaryexpression54 = new Integer(16, false);
        this.StoredValue = new Integer(16, false);
    }
    
    public virtual void Tick()
    {
        this.StoredValue.ValueCopy(this.Value);
    }
}

public class Register_euclid_done : IRegister
{
    
    internal Integer Value;
    
    internal String EntityName;
    
    /// The cycle for which the value field was last evaluated (debug purpose)
    internal Int32 Cycle;
    
    // The constant value 0
    // The constant value 0
    // The constant value 0
    // The constant value 0
    // The constant value 0
    // The constant value 0
    // The constant value 0
    // The constant value 0
    // The constant value 0
    // The constant value 0
    internal Integer Constant_0;
    
    // Used to evaluate expression: m == 0
    // Used to evaluate expression: m == 0
    // Used to evaluate expression: m == 0
    // Used to evaluate expression: m == 0
    internal Integer Value_binaryexpression29;
    
    // Used to evaluate expression: n == 0
    // Used to evaluate expression: n == 0
    // Used to evaluate expression: n == 0
    // Used to evaluate expression: n == 0
    internal Integer Value_binaryexpression32;
    
    // Used to evaluate expression: (m == 0) | (n == 0)
    // Used to evaluate expression: (m == 0) | (n == 0)
    // Used to evaluate expression: (m == 0) | (n == 0)
    // Used to evaluate expression: (m == 0) | (n == 0)
    internal Integer Value_binaryexpression33;
    
    /// Caches the previous register value.
    internal Integer StoredValue;
    
    public virtual void Evaluate()
    {
      switch(Simulator.controller_euclid_ctl.CurrentControlStep)
      {
      case 0:
        this.Value.ValueCopy(this.Constant_0);
        break;
      case 2:
        if ((Simulator.register_euclid_m.StoredValue == this.Constant_0))
        {
            this.Value_binaryexpression29 = Integer.One;
        }
        else
        {
            this.Value_binaryexpression29 = Integer.Zero;
        }
        if ((Simulator.register_euclid_n.StoredValue == this.Constant_0))
        {
            this.Value_binaryexpression32 = Integer.One;
        }
        else
        {
            this.Value_binaryexpression32 = Integer.Zero;
        }
        Integer.Or(ref this.Value_binaryexpression33, this.Value_binaryexpression29, this.Value_binaryexpression32);
        this.Value.ValueCopy(this.Value_binaryexpression33);
        break;
      case 3:
        if ((Simulator.register_euclid_m.StoredValue == this.Constant_0))
        {
            this.Value_binaryexpression29 = Integer.One;
        }
        else
        {
            this.Value_binaryexpression29 = Integer.Zero;
        }
        if ((Simulator.register_euclid_n.StoredValue == this.Constant_0))
        {
            this.Value_binaryexpression32 = Integer.One;
        }
        else
        {
            this.Value_binaryexpression32 = Integer.Zero;
        }
        Integer.Or(ref this.Value_binaryexpression33, this.Value_binaryexpression29, this.Value_binaryexpression32);
        this.Value.ValueCopy(this.Value_binaryexpression33);
        break;
      case 4:
        if ((Simulator.register_euclid_m.StoredValue == this.Constant_0))
        {
            this.Value_binaryexpression29 = Integer.One;
        }
        else
        {
            this.Value_binaryexpression29 = Integer.Zero;
        }
        if ((Simulator.register_euclid_n.StoredValue == this.Constant_0))
        {
            this.Value_binaryexpression32 = Integer.One;
        }
        else
        {
            this.Value_binaryexpression32 = Integer.Zero;
        }
        Integer.Or(ref this.Value_binaryexpression33, this.Value_binaryexpression29, this.Value_binaryexpression32);
        this.Value.ValueCopy(this.Value_binaryexpression33);
        break;
      case 5:
        if ((Simulator.register_euclid_m.StoredValue == this.Constant_0))
        {
            this.Value_binaryexpression29 = Integer.One;
        }
        else
        {
            this.Value_binaryexpression29 = Integer.Zero;
        }
        if ((Simulator.register_euclid_n.StoredValue == this.Constant_0))
        {
            this.Value_binaryexpression32 = Integer.One;
        }
        else
        {
            this.Value_binaryexpression32 = Integer.Zero;
        }
        Integer.Or(ref this.Value_binaryexpression33, this.Value_binaryexpression29, this.Value_binaryexpression32);
        this.Value.ValueCopy(this.Value_binaryexpression33);
        break;
      case 6:
        this.Value.ValueCopy(this.Constant_0);
        break;
      }
    }
    
    public virtual void Initialize()
    {
        this.Value = new Integer(1, false);
        this.Constant_0 = new Integer(2, false);
        this.Value_binaryexpression29 = new Integer(1, false);
        this.Value_binaryexpression32 = new Integer(1, false);
        this.Value_binaryexpression33 = new Integer(1, false);
        this.StoredValue = new Integer(1, false);
    }
    
    public virtual void Tick()
    {
        this.StoredValue.ValueCopy(this.Value);
    }
}

public class Register_euclid_factor : IRegister
{
    
    internal Integer Value;
    
    internal String EntityName;
    
    /// The cycle for which the value field was last evaluated (debug purpose)
    internal Int32 Cycle;
    
    // The constant value 0
    // The constant value 0
    internal Integer Constant_0;
    
    // The constant value 1
    internal Integer Constant_1;
    
    // Used to evaluate expression: factor + 1
    internal Integer Value_binaryexpression93;
    
    /// Caches the previous register value.
    internal Integer StoredValue;
    
    public virtual void Evaluate()
    {
      switch(Simulator.controller_euclid_ctl.CurrentControlStep)
      {
      case 0:
        this.Value.ValueCopy(this.Constant_0);
        break;
      case 5:
        Integer.Add(ref this.Value_binaryexpression93, Simulator.register_euclid_factor.StoredValue, this.Constant_1);
        this.Value.ValueCopy(this.Value_binaryexpression93);
        break;
      case 6:
        this.Value.ValueCopy(this.Constant_0);
        break;
      }
    }
    
    public virtual void Initialize()
    {
        this.Value = new Integer(16, false);
        this.Constant_0 = new Integer(2, false);
        this.Constant_1 = new Integer(2, "1", false);
        this.Value_binaryexpression93 = new Integer(16, false);
        this.StoredValue = new Integer(16, false);
    }
    
    public virtual void Tick()
    {
        this.StoredValue.ValueCopy(this.Value);
    }
}

